import java.util.Scanner;

public class D_1_31 {
    public static void main(String[] args) {
        int L,M,num = 0;

        Scanner sc = new Scanner(System.in);
        L = sc.nextInt();
        M = sc.nextInt();
        int[] a = new int[L+1];
        for (int i = 0; i < L+1; i++) {
            a[i] = 1;
        }
        for (int i = 0; i < M; i++) {
            int t1,t2;
            t1 = sc.nextInt();
            t2 = sc.nextInt();
            for (int j = t1; j <= t2; j++) {
                a[j] = 0;
            }
        }
        for (int i = 0; i < L+1; i++) {
            if(a[i] == 1)
                num++;
        }
        System.out.println(num);
    }
}
